﻿using FlowCanvas.Nodes;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class SetStreetEventNpcTransformScale : CallableActionNode<int,string,Vector3>
    {
        public override void Invoke(int streetNpcId, string nodePath, Vector3 scale)
        {
            if (streetNpcId != LibertyAIUtils.PLAYER_AI_ID)
            {
                var m = StreetEventManager.GetInstance("").GetMonster(streetNpcId);
                if (m != null)
                {
                    var aiEntity = LibertyAIUtils.AIManager.NpcBirthManager.GetNpc(m.uniqueId);
                    if (aiEntity != null)
                    {
                        Transform transform = aiEntity.viewer.animator.transform.Find(nodePath);
                        if (transform)
                        {
                            transform.localScale = scale;
                        }
                    }
                }
            }
            else
            {
                Transform transform = LibertyAIUtils.PlayerController.playerEntity.AIEntity.viewer.animator.transform.Find(nodePath);
                if (transform)
                {
                    transform.localScale = scale;
                }
            }
        }
    }
}